package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.entity.NursingLevel;
import com.zzyl.vo.NursingLevelVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface NursingLevelMapper {
    /**
     * 分页查询护理等级
     * @param name
     * @param status
     * @return
     */
    Page<NursingLevelVo> listByPage(String name, Integer status);

    /**
     * 新增护理等级
     * @param nursingLevel
     */
    void insert(NursingLevel nursingLevel);

    /**
     * 根据id查询护理等级
     * @param id
     * @return
     */
    @Select("select nl.*,np.plan_name planName from nursing_level nl left join nursing_plan np on nl.plan_id = np.id where nl.id = #{id}")
    NursingLevel getById(Long id);

    /**
     * 修改护理等级
     * @param nursingLevel
     */
    void update(NursingLevel nursingLevel);

    /**
     * 删除护理等级
     * @param id
     */
    @Delete("delete from nursing_level where id = #{id}")
    void delete(Long id);

    /**
     * 根据plan_id查询护理等级
     * @param id
     * @return
     */
    @Select("select * from nursing_level where plan_id = #{id}")
    NursingLevel getByPlanId(Long id);

    /**
     * 修改护理等级状态
     * @param id
     * @param status
     */
    @Update("update nursing_level set status = #{status} where id = #{id}")
    void updateStatus(Long id, Integer status);

    /**
     * 查询所有护理等级
     * @return
     */
    @Select("select * from nursing_level")
    List<NursingLevelVo> listAll();
}
